package com.pocketsweet.ui.uilib.wheelview;

import android.view.View;

import com.pocketsweet.R;

public class WheelBoredTime {

	private View view;
	private WheelView wv_year;
	private WheelView wv_month;
	private WheelView wv_day;
	private WheelView wv_hours;
	private WheelView wv_mins;
	public int screenheight;
	private boolean hasSelectTime;
	private static int START_YEAR = 0, END_YEAR = 23;

	public View getView() {
		return view;
	}

	public void setView(View view) {
		this.view = view;
	}

	public static int getSTART_YEAR() {
		return START_YEAR;
	}

	public static void setSTART_YEAR(int sTART_YEAR) {
		START_YEAR = sTART_YEAR;
	}

	public static int getEND_YEAR() {
		return END_YEAR;
	}

	public static void setEND_YEAR(int eND_YEAR) {
		END_YEAR = eND_YEAR;
	}

	public WheelBoredTime(View view) {
		super();
		this.view = view;
		hasSelectTime = false;
		setView(view);
	}

	public WheelBoredTime(View view, boolean hasSelectTime) {
		super();
		this.view = view;
		this.hasSelectTime = hasSelectTime;
		setView(view);
	}

	public void initDateTimePicker() {
		this.initDateTimePicker(23, 8);
	}

	/**
	 * @Description: TODO 弹出选择器
	 */
	public void initDateTimePicker(int year, int month) {

		// 年
		wv_year = (WheelView) view.findViewById(R.id.year);
		wv_year.setAdapter(new BorderWheelAdapter());// 设置"年"的显示数据
		wv_year.setCyclic(true);// 可循环滚动
		wv_year.setCurrentItem(year);// 初始化时显示的数据
		wv_year.setLabel("~   ");

		// 月
		wv_month = (WheelView) view.findViewById(R.id.month);
		wv_month.setAdapter(new BorderWheelAdapter(0, 9));
		wv_month.setCyclic(true);
		wv_month.setCurrentItem(month);

		wv_day = (WheelView) view.findViewById(R.id.day);
		wv_hours = (WheelView) view.findViewById(R.id.hour);
		wv_mins = (WheelView) view.findViewById(R.id.min);
		wv_day.setVisibility(View.GONE);
		wv_hours.setVisibility(View.GONE);
		wv_mins.setVisibility(View.GONE);

		// 根据屏幕密度来指定选择器字体的大小(不同屏幕可能不同)
		int textSize = 0;
		if (hasSelectTime)
			textSize = (screenheight / 100) * 3;
		else
			textSize = (screenheight / 100) * 4;
		wv_day.TEXT_SIZE = textSize;
		wv_month.TEXT_SIZE = textSize;
		wv_year.TEXT_SIZE = textSize;

	}

	public int getStartTime() {
		return wv_year.getCurrentItem();
	}

	public int getEndTime() {
		return wv_month.getCurrentItem();

	}
}
